from rest_framework import serializers
from .models import ComicCategory, Comic, ComicDetails, Comment,Likes,NumbeOfVisits
from user.models import User


class ComicCategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = ComicCategory
        fields = ['id', 'name']


class ComicSerializer(serializers.ModelSerializer):
    class Meta:
        model = Comic
        fields = ['id', 'name', 'comic_img', 'comic_category', 'sections', 'pub_sections', 'end_if', 'comic_detail',
                  'episodes_list','NumofView']


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ['id', 'username', 'icon']
        extra_kwargs = {
            "icon": {"read_only": True},

        }

class CommentLikeSerializer(serializers.ModelSerializer):
    class Meta:
        model=Likes
        fields="__all__"

class CommentSerializer(serializers.ModelSerializer):
    class Meta:
        model = Comment
        fields = ['id', 'user', 'content', 'time', 'parent', 'comic',"user_info",'likes']


    likes=CommentLikeSerializer(read_only=True)

    user_info= UserSerializer(read_only=True)

class NumOfComicSerializer(serializers.ModelSerializer):
    class Meta:
        model=NumbeOfVisits
        fields="__all__"













